<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Bootstrap
 *
 * @author zxcms
 */
class H_Application_Module_Bootstrap extends Zend_Application_Module_Bootstrap
{
    //Tu dong chay de nap tat ca cac module hien co khong tinh module cms
    protected function _initAdapterModule(){
        array_push(H_G::$ALL_SITE_MODULE, strtolower($this->getModuleName()));
    }
    protected function _initModuleTranslate(){
        $translate_path = APPLICATION_PATH."/languages/";
        $langConfig = $this->_application->getOption('languages');
        $defaultLang = $langConfig['default'];
        try{
                $translate = new H_Translate(array(
                        'adapter' => 'array',
                        'content' => $translate_path.$defaultLang.".php",
                        'locale'  => $defaultLang
                ));
                $files = scandir($translate_path);
                foreach ($files as $file){
                    if (is_file($translate_path.$file)){
                        if ($file != $defaultLang.'.php'){
                            $lang = str_replace(".php", "", $file);
                            $translate->addTranslation(array(
                                'content' => $translate_path.$file,
                                'locale'  => $lang
                            ));
                        }
                    }
                }

        }catch(Zend_Translate_Exception $e){
            H_E::printDie("Translate Error");
        }
        $translate->setLocale($defaultLang);
        Zend_Registry::set(H_G::T_TRANSLATE, $translate);
    }
    protected function _initView(){
       $view = Zend_Registry::get('ZEND_VIEW_KEY');
       $view->setTranslate(Zend_Registry::get(H_G::T_TRANSLATE));
    }
}
?>